<?php
/*========================================= JooSam =========================================/
/																							/
/	Extention:		JooSam																	/
/	Created by:		ScriptPlanet.eu															/
/	Site:			http://www.scriptplanet.eu												/
/	Email:			support@scriptplanet.eu													/
/	Support:		http://www.scriptplanet.eu/support										/
/	Copyright:		2011 (c) ScriptPlanet.eu												/
/	License:		CC BY-NC-ND 3.0 ~ http://creativecommons.org/licenses/by-nc-nd/3.0/		/
/	File Version:	0001																	/
/																							/
/========================================== JooSam ========================================*/
// Joomla Security
defined('_JEXEC') or die;
JHtml::_('behavior.tooltip');

$data = $this->request;

if($data == ''){
	$type = 'error';
	$info = JText::_('COM_JOOSAM_REQUEST_ERROR_UNKNOWN');
	$text = 'blocked';
	$xtra = 'noinfo';
}
else{
	$type = $data['type'];
	$info = $data['info'];
	$text = $data['text'];
	$xtra = $data['xtra'];
}
?>

<form id="reqOutput" name="reqOutput" action="<?php echo JRoute::_('index.php?view=request&layout=request');?>" method="post">
	<input type="hidden" id="jsamType" name="jsamType" value="<?php echo $type; ?>"/>
	<input type="hidden" id="jsamInfo" name="jsamInfo" value="<?php echo $info; ?>"/>
	<input type="hidden" id="jsamText" name="jsamText" value="<?php echo $text; ?>"/>
	<input type="hidden" id="jsamXtra" name="jsamXtra" value="<?php echo $xtra; ?>"/>
</form>

<script>
	function checkform(){
		// Checks hole form for filled data
		var jsamType = document.getElementById('jsamType').value;
		var jsamInfo = document.getElementById('jsamInfo').value;
		var jsamText = document.getElementById('jsamText').value;
		var jsamXtra = document.getElementById('jsamXtra').value;

		var error = 0;

		if(jsamXtra == ''){
			alert("<?php echo JText::_('COM_JOOSAM_REQUEST_ALERT_NOIDDATA'); ?>");
			error = error+1;
		}
		if(jsamText == ''){
			alert("<?php echo JText::_('COM_JOOSAM_REQUEST_ALERT_NOTEXTMSG'); ?>");
			error = error+1;
		}
		if(jsamInfo == ''){
			alert("<?php echo JText::_('COM_JOOSAM_REQUEST_ALERT_NOJSAMTXT'); ?>");
			error = error+1;
		}

		if(jsamType == ''){
			alert("<?php echo JText::_('COM_JOOSAM_REQUEST_ALERT_NOTYPE'); ?>");
			error = error+1;
		}

		if(error == 0){
			document.reqOutput.submit();
		}
	}
	document.onload = checkform();
</script>